﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;


using Webchatting.Common;
using Webchatting.Dal;

public partial class server_Portraitedit : System.Web.UI.Page
{
    public string RUPortrait = "0";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            OperationRU RUserPedit = new OperationRU();
            IList<string> ilist = RUserPedit.GetRUPortrait(Request["RUId"]);

            Image1.ImageUrl = ilist[2];

            RUPortrait = ilist[2];
            TextBox1.Text = ilist[1];
            TextBox2.Text = ilist[3];
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string img = Guid.NewGuid().ToString() + "." + FileUpload1.FileName.Split('.')[1].ToString();
        string serverpath = Server.MapPath("/server/Portrait/") + img;

        if (FileUpload1.PostedFile.FileName != "")
        {
            FileUpload1.PostedFile.SaveAs(serverpath);
        }

        FormsIdentity id = (FormsIdentity)User.Identity;
        OperationRU ORUser = new OperationRU();
        ORUser.EditRUPortrait(id.Ticket.UserData.Split("@".ToCharArray())[0],
            (FileUpload1.PostedFile.FileName != "") ? "/server/Portrait/" + img : RUPortrait, TextBox1.Text.Trim(), TextBox2.Text.Trim());
       
        Response.Write("<script>alert('修改个人信息成功！');window.parent.location.href='RUIndex.aspx';</script>");
    }

    protected void TextBox2_TextChanged(object sender, EventArgs e)
    {

    }
}
